namespace DotNetNuke.Services.Wizards
{
    using DotNetNuke.Entities.Modules;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The Wizard class defines a custom base class inherited by all
    /// Wizard controls.  Wizard itself inherits from PortalModuleBase.
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// [cnurse]	10/10/2004	created
    /// </history>
    /// -----------------------------------------------------------------------------
    public class Wizard : PortalModuleBase
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        //("cmdBack")]
        private LinkButton _cmdBack;
        //("cmdBackIcon")]
        private ImageButton _cmdBackIcon;
        //("cmdCancel")]
        private LinkButton _cmdCancel;
        //("cmdCancelIcon")]
        private ImageButton _cmdCancelIcon;
        //("cmdFinish")]
        private LinkButton _cmdFinish;
        //("cmdFinishIcon")]
        private ImageButton _cmdFinishIcon;
        //("cmdHelp")]
        private LinkButton _cmdHelp;
        //("cmdHelpIcon")]
        private ImageButton _cmdHelpIcon;
        //("cmdNext")]
        private LinkButton _cmdNext;
        //("cmdNextIcon")]
        private ImageButton _cmdNextIcon;
        //("imgIcon")]
        private Image _imgIcon;
        //("lblHelpTitle")]
        private Label _lblHelpTitle;
        //("lblPages")]
        private Label _lblPages;
        //("lblTitle")]
        private Label _lblTitle;
        //("WizardHelp")]
        private HtmlGenericControl _WizardHelp;
        //("WizardHelpPane")]
        private HtmlTableCell _WizardHelpPane;
        private bool m_EnableBack;
        private bool m_EnableFinish;
        private bool m_EnableNext;
        private WizardPage m_FailurePage;
        private WizardPageCollection m_Pages;
        private WizardPage m_SuccessPage;

        public event WizardEventHandler AfterPageChanged;

        public event WizardCancelEventHandler BeforePageChanged;

        public event WizardEventHandler FinishWizard;

        public Wizard()
        {
            base.Init += new EventHandler(this.Page_Init);
            base.Load += new EventHandler(this.Page_Load);
            List<WeakReference> refObjectHelperL0 = __ENCList;
            lock (refObjectHelperL0)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.m_Pages = new WizardPageCollection();
            this.m_EnableBack = true;
            this.m_EnableNext = true;
            this.m_EnableFinish = true;
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddCommandButton adds a Button to the Button Panel
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="icon">The ImageButton to Add</param>
        /// <param name="link">The LinkButton to Add</param>
        /// <param name="Key">The Resource Key for the Text/Help</param>
        /// <param name="imageUrl">The Image Url</param>
        /// <param name="causesValidation">Flag set the button to not cause validation</param>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private HtmlTable AddCommandButton(ref ImageButton icon, ref LinkButton link, string Key, string imageUrl, bool causesValidation)
        {
            HtmlTable table = new HtmlTable();
            HtmlTableRow row = new HtmlTableRow();
            HtmlTableCell container = new HtmlTableCell();
            table.Attributes.Add("class", "WizardButton");
            table.Rows.Add(row);
            row.Cells.Add(container);
            icon = new ImageButton();
            icon.ImageUrl = "~/images/" + imageUrl;
            icon.ToolTip = DotNetNuke.Services.Localization.Localization.GetString(Key + ".Help");
            link = new LinkButton();
            link.CssClass = "CommandButton";
            link.Text = DotNetNuke.Services.Localization.Localization.GetString(Key);
            link.ToolTip = DotNetNuke.Services.Localization.Localization.GetString(Key + ".Help");
            link.CausesValidation = causesValidation;
            container.Controls.Add(icon);
            container.Controls.Add(new LiteralControl("&nbsp;"));
            container.Controls.Add(link);
            return table;
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddFooter adds the Footer to the Wizard
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void AddFooter()
        {
            HtmlTable Wizard = (HtmlTable) this.FindControl("Wizard");
            HtmlTableRow FooterRow = new HtmlTableRow();
            HtmlTableCell WizardFooter = new HtmlTableCell();
            WizardFooter.ColSpan = 2;
            WizardFooter.Width = "100%";
            HtmlTable table = new HtmlTable();
            table.Width = "100%";
            HtmlTableRow row = new HtmlTableRow();
            HtmlTableCell cell = new HtmlTableCell();
            this.lblPages = new Label();
            this.lblPages.CssClass = "SubHead";
            cell.Align = "Left";
            cell.Width = "200";
            cell.Controls.Add(this.lblPages);
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            cell.Width = "160";
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            ImageButton refObjectHelperS0 = this.cmdBackIcon;
            LinkButton refObjectHelperS1 = this.cmdBack;
            this.cmdBack = refObjectHelperS1;
            this.cmdBackIcon = refObjectHelperS0;
            cell.Controls.Add(this.AddCommandButton(ref refObjectHelperS0, ref refObjectHelperS1, "cmdBack", "lt.gif", false));
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            refObjectHelperS0 = this.cmdNextIcon;
            refObjectHelperS1 = this.cmdNext;
            this.cmdNext = refObjectHelperS1;
            this.cmdNextIcon = refObjectHelperS0;
            cell.Controls.Add(this.AddCommandButton(ref refObjectHelperS0, ref refObjectHelperS1, "cmdNext", "rt.gif", true));
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            refObjectHelperS0 = this.cmdFinishIcon;
            refObjectHelperS1 = this.cmdFinish;
            this.cmdFinish = refObjectHelperS1;
            this.cmdFinishIcon = refObjectHelperS0;
            cell.Controls.Add(this.AddCommandButton(ref refObjectHelperS0, ref refObjectHelperS1, "cmdFinish", "end.gif", true));
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            refObjectHelperS0 = this.cmdCancelIcon;
            refObjectHelperS1 = this.cmdCancel;
            this.cmdCancel = refObjectHelperS1;
            this.cmdCancelIcon = refObjectHelperS0;
            cell.Controls.Add(this.AddCommandButton(ref refObjectHelperS0, ref refObjectHelperS1, "cmdCancel", "cancel.gif", false));
            row.Cells.Add(cell);
            table.Rows.Add(row);
            WizardFooter.Controls.Add(table);
            this.cmdNext.Command += new CommandEventHandler(this.NextPage);
            this.cmdNextIcon.Command += new CommandEventHandler(this.NextPage);
            this.cmdBack.Command += new CommandEventHandler(this.PreviousPage);
            this.cmdBackIcon.Command += new CommandEventHandler(this.PreviousPage);
            this.cmdFinish.Command += new CommandEventHandler(this.Finish);
            this.cmdFinishIcon.Command += new CommandEventHandler(this.Finish);
            this.cmdCancel.Command += new CommandEventHandler(this.Cancel);
            this.cmdCancelIcon.Command += new CommandEventHandler(this.Cancel);
            WizardFooter.Attributes.Add("class", "WizardFooter");
            WizardFooter.Height = "22";
            WizardFooter.VAlign = "middle";
            FooterRow.Cells.Add(WizardFooter);
            Wizard.Rows.Add(FooterRow);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddHeader adds the Header to the Wizard
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void AddHeader()
        {
            HtmlTable Wizard = (HtmlTable) this.FindControl("Wizard");
            HtmlTableRow HeaderRow = new HtmlTableRow();
            HtmlTableCell WizardHeader = new HtmlTableCell();
            WizardHeader.ColSpan = 2;
            WizardHeader.Width = "100%";
            HtmlTable headerTable = new HtmlTable();
            headerTable.Width = "100%";
            HtmlTableRow row = new HtmlTableRow();
            HtmlTableCell cell = new HtmlTableCell();
            cell.Width = "40";
            this.imgIcon = new Image();
            cell.Controls.Add(this.imgIcon);
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            cell.Width = "15";
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            cell.Width = "400";
            cell.VAlign = "middle";
            this.lblTitle = new Label();
            this.lblTitle.CssClass = "Head";
            cell.Controls.Add(this.lblTitle);
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            cell.Width = "15";
            row.Cells.Add(cell);
            cell = new HtmlTableCell();
            cell.Align = "right";
            ImageButton refObjectHelperS0 = this.cmdHelpIcon;
            LinkButton refObjectHelperS1 = this.cmdHelp;
            this.cmdHelp = refObjectHelperS1;
            this.cmdHelpIcon = refObjectHelperS0;
            cell.Controls.Add(this.AddCommandButton(ref refObjectHelperS0, ref refObjectHelperS1, "cmdHelp", "help.gif", false));
            row.Cells.Add(cell);
            headerTable.Rows.Add(row);
            WizardHeader.Controls.Add(headerTable);
            this.cmdHelp.Command += new CommandEventHandler(this.ShowHelp);
            this.cmdHelpIcon.Command += new CommandEventHandler(this.ShowHelp);
            WizardHeader.Attributes.Add("class", "WizardHeader");
            HeaderRow.Cells.Add(WizardHeader);
            Wizard.Rows.Insert(0, HeaderRow);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPage adds a Wizard Page to the Control
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="title">The Page's Title</param>
        /// <param name="icon">The Page's Icon</param>
        /// <param name="ctl">The Page's Control</param>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void AddPage(string title, string icon, Control ctl)
        {
            this.AddPage(title, icon, ctl, WizardPageType.Content, "");
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPage adds a Wizard Page to the Control
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="title">The Page's Title</param>
        /// <param name="icon">The Page's Icon</param>
        /// <param name="ctl">The Page's Control</param>
        /// <param name="help">The Page's Help Text</param>
        /// <history>
        /// [cnurse]	11/03/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void AddPage(string title, string icon, Control ctl, string help)
        {
            this.AddPage(title, icon, ctl, WizardPageType.Content, help);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPage adds a Wizard Page to the Control
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="title">The Page's Title</param>
        /// <param name="icon">The Page's Icon</param>
        /// <param name="ctl">The Page's Control</param>
        /// <param name="type">The type of the Wizard Page</param>
        /// <param name="help">The Page's Help Text</param>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// [cnurse]    11/03/2004  Added help parameter
        /// </history>
        /// -----------------------------------------------------------------------------
        public void AddPage(string title, string icon, Control ctl, WizardPageType type, string help)
        {
            switch (((int) type))
            {
                case 0:
                    this.Pages.Add(title, icon, ctl, help);
                    break;

                case 1:
                    this.m_SuccessPage = new WizardPage(title, icon, ctl, type, help);
                    break;

                case 2:
                    this.m_FailurePage = new WizardPage(title, icon, ctl, type, help);
                    break;
            }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Cancel runs when the Cancel Button is clicked and returns the user to the
        /// Previous Location
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	11/2/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Cancel(object sender, CommandEventArgs e)
        {
            try
            {
                this.Response.Redirect("~/Default.aspx", true);
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException((PortalModuleBase) this, exc);
                
            }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ConfigureWizard sets up the Wizard Framework (creates the structure and injects
        /// the buttons
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void ConfigureWizard()
        {
            HtmlTable Wizard = (HtmlTable) this.FindControl("Wizard");
            Wizard.Attributes.Add("class", "Wizard");
            Wizard.CellPadding = 0;
            Wizard.CellSpacing = 0;
            Wizard.Border = 0;
            HtmlTableCell WizardBody = (HtmlTableCell) this.FindControl("WizardBody");
            WizardBody.Attributes.Add("class", "WizardBody");
            WizardBody.VAlign = "top";
            HtmlTableRow WizardRow = (HtmlTableRow) WizardBody.Parent;
            this.WizardHelpPane = new HtmlTableCell();
            this.WizardHelpPane.Attributes.Add("class", "WizardHelp");
            this.WizardHelpPane.VAlign = "top";
            this.WizardHelpPane.Visible = false;
            HtmlTable table = new HtmlTable();
            table.Width = "180";
            HtmlTableRow row = new HtmlTableRow();
            HtmlTableCell cell = new HtmlTableCell();
            this.lblHelpTitle = new Label();
            this.lblHelpTitle.CssClass = "SubHead";
            this.lblHelpTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("cmdHelp");
            cell.Controls.Add(this.lblHelpTitle);
            cell.Controls.Add(new LiteralControl("<hr>"));
            row.Cells.Add(cell);
            table.Rows.Add(row);
            row = new HtmlTableRow();
            cell = new HtmlTableCell();
            cell.VAlign = "top";
            this.WizardHelp = new HtmlGenericControl();
            this.WizardHelp.Attributes.Add("class", "WizardHelpText");
            cell.Controls.Add(this.WizardHelp);
            row.Cells.Add(cell);
            table.Rows.Add(row);
            this.WizardHelpPane.Controls.Add(table);
            WizardRow.Cells.Add(this.WizardHelpPane);
            this.AddHeader();
            this.AddFooter();
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DisplayCurrentPage displays the current selected Page
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void DisplayCurrentPage()
        {
            WizardPage wizPage = this.Pages[this.CurrentPage];
            this.DisplayPage(this.CurrentPage, wizPage, this.EnableBack, this.EnableNext, this.EnableFinish);
            this.DisplayHelp(false);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DisplayFailurePage displays the Wizards failure page
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void DisplayFailurePage(string message)
        {
            if (this.m_FailurePage == null)
            {
                WizardSuccess ctlSuccess = (WizardSuccess) this.LoadControl("~/admin/Wizards/Success.ascx");
                ctlSuccess.Message = message;
                ctlSuccess.Type = false;
                HtmlTableCell WizardBody = (HtmlTableCell) this.FindControl("WizardBody");
                WizardBody.Controls.Add(ctlSuccess);
                this.m_FailurePage = new WizardPage("Wizard Error", "", ctlSuccess, WizardPageType.Failure);
            }
            this.DisplayPage(-1, this.m_FailurePage, false, false, false);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DisplayHelp shows/hides the Help Panel
        /// the buttons
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="show">Flag that determines whether the Help Panel is displayed/hidden</param>
        /// <history>
        /// [cnurse]	11/04/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void DisplayHelp(bool show)
        {
            if (show)
            {
                WizardPage wizPage = this.Pages[this.CurrentPage];
                this.lblHelpTitle.Text = DotNetNuke.Services.Localization.Localization.GetString("Help") + " - " + wizPage.Title;
                this.WizardHelp.InnerHtml = wizPage.Help;
            }
            else
            {
                this.lblHelpTitle.Text = "";
                this.WizardHelp.InnerHtml = "";
            }
            this.WizardHelpPane.Visible = show;
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DisplayPage displays a specific Page
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="wizPage">The Page to display</param>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void DisplayPage(int pageNo, WizardPage wizPage, bool ShowBack, bool ShowNext, bool ShowFinish)
        {
            if (wizPage == null)
            {
                wizPage = new WizardPage();
            }
            int refIntHelperL0 = this.Pages.Count - 1;
            for (int iPage = 0; iPage <= refIntHelperL0; iPage++)
            {
                WizardPage pge = this.Pages[iPage];
                pge.Control.Visible = false;
            }
            wizPage.Control.Visible = true;
            if (wizPage.Icon == "")
            {
                this.imgIcon.ImageUrl = "~/images/1x1.gif";
            }
            else
            {
                this.imgIcon.ImageUrl = wizPage.Icon;
            }
            this.lblTitle.Text = wizPage.Title;
            if ((this.CurrentPage > 0) & ShowBack)
            {
                this.cmdBack.Enabled = true;
                this.cmdBackIcon.Enabled = true;
            }
            else
            {
                this.cmdBack.Enabled = false;
                this.cmdBackIcon.Enabled = false;
            }
            if ((this.CurrentPage < (this.m_Pages.Count - 1)) & ShowNext)
            {
                this.cmdNext.Enabled = true;
                this.cmdNextIcon.Enabled = true;
            }
            else
            {
                this.cmdNext.Enabled = false;
                this.cmdNextIcon.Enabled = false;
            }
            if ((this.CurrentPage >= this.FinishPage) & ShowFinish)
            {
                this.cmdFinish.Enabled = true;
                this.cmdFinishIcon.Enabled = true;
            }
            else
            {
                this.cmdFinish.Enabled = false;
                this.cmdFinishIcon.Enabled = false;
            }
            if (wizPage.Help == "")
            {
                this.cmdHelp.Enabled = false;
                this.cmdHelpIcon.Enabled = false;
            }
            else
            {
                this.cmdHelp.Enabled = true;
                this.cmdHelpIcon.Enabled = true;
            }
            this.lblPages.Text = string.Format(DotNetNuke.Services.Localization.Localization.GetString("Pages"), this.CurrentPage + 1, this.Pages.Count);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DisplaySuccessPage displays the Wizards success page
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/09/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void DisplaySuccessPage(string message)
        {
            if (this.m_SuccessPage == null)
            {
                WizardSuccess ctlSuccess = (WizardSuccess) this.LoadControl("~/admin/Wizards/Success.ascx");
                ctlSuccess.Message = message;
                HtmlTableCell WizardBody = (HtmlTableCell) this.FindControl("WizardBody");
                WizardBody.Controls.Add(ctlSuccess);
                this.m_SuccessPage = new WizardPage("Congratulations", "", ctlSuccess, WizardPageType.Success);
            }
            this.DisplayPage(-1, this.m_SuccessPage, false, false, false);
            this.DisplayHelp(false);
            this.cmdCancel.Enabled = true;
            this.cmdCancelIcon.Enabled = true;
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// EnableCommand allows a Wizard to Enable/Disable any of the four Command
        /// options
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="cmd">The WizardCommand to Enable/Display</param>
        /// <param name="enable">A flag that determines whether the Commadn is Enabled (true)
        /// or Disabled (False)</param>
        /// <history>
        /// [cnurse]	10/12/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void EnableCommand(WizardCommand cmd, bool enable)
        {
            switch (((int) cmd))
            {
                case 0:
                    this.cmdBack.Enabled = enable;
                    break;

                case 1:
                    this.cmdNext.Enabled = enable;
                    break;

                case 2:
                    this.cmdFinish.Enabled = enable;
                    break;

                case 3:
                    this.cmdCancel.Enabled = enable;
                    break;
            }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Finish runs when the Back Button is clicked and raises a FinishWizard
        /// Event
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/10/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Finish(object sender, CommandEventArgs e)
        {
            WizardEventArgs we = new WizardEventArgs(this.CurrentPage, this.Pages);
            this.OnFinishWizard(we);
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// NextPage runs when the Next Button is clicked and raises a NextPage
        /// Event
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/10/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void NextPage(object sender, CommandEventArgs e)
        {
            if (this.CurrentPage < (this.Pages.Count - 1))
            {
                int PrevPage = this.CurrentPage;
                WizardCancelEventArgs wce = new WizardCancelEventArgs(this.CurrentPage + 1, PrevPage, this.Pages);
                this.OnBeforePageChanged(wce);
                if (!wce.Cancel)
                {
                    this.CurrentPage++;
                    WizardEventArgs we = new WizardEventArgs(this.CurrentPage, PrevPage, this.Pages);
                    this.OnAfterPageChanged(we);
                }
            }
            this.DisplayCurrentPage();
        }

        protected virtual void OnAfterPageChanged(WizardEventArgs e)
        {
            WizardEventHandler refObjectHelperS0 = this.AfterPageChanged;
            if (refObjectHelperS0 != null)
            {
                refObjectHelperS0(this, e);
            }
        }

        protected virtual void OnBeforePageChanged(WizardCancelEventArgs e)
        {
            WizardCancelEventHandler refObjectHelperS0 = this.BeforePageChanged;
            if (refObjectHelperS0 != null)
            {
                refObjectHelperS0(this, e);
            }
        }

        protected virtual void OnFinishWizard(WizardEventArgs e)
        {
            WizardEventHandler refObjectHelperS0 = this.FinishWizard;
            if (refObjectHelperS0 != null)
            {
                refObjectHelperS0(this, e);
            }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Init runs when the Control is Constructed
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/10/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Page_Init(object sender, EventArgs e)
        {
            this.ConfigureWizard();
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the Control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	11/2/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Page_Load(object sender, EventArgs e)
        {
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// PreviousPage runs when the Back Button is clicked and raises a PreviousPage
        /// Event
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/10/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void PreviousPage(object sender, CommandEventArgs e)
        {
            if (this.CurrentPage > 0)
            {
                int PrevPage = this.CurrentPage;
                WizardCancelEventArgs wce = new WizardCancelEventArgs(this.CurrentPage - 1, PrevPage, this.Pages);
                this.OnBeforePageChanged(wce);
                if (!wce.Cancel)
                {
                    this.CurrentPage--;
                    WizardEventArgs we = new WizardEventArgs(this.CurrentPage, PrevPage, this.Pages);
                    this.OnAfterPageChanged(we);
                }
            }
            this.DisplayCurrentPage();
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ShowHelp runs when the Back Buttn is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	11/3/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void ShowHelp(object sender, CommandEventArgs e)
        {
            this.DisplayHelp(!this.WizardHelpPane.Visible);
        }

        private LinkButton cmdBack
        {
           
            get
            {
                return this._cmdBack;
            }
            
            set
            {
                this._cmdBack = value;
            }
        }

        private ImageButton cmdBackIcon
        {
           
            get
            {
                return this._cmdBackIcon;
            }
            
            set
            {
                this._cmdBackIcon = value;
            }
        }

        private LinkButton cmdCancel
        {
           
            get
            {
                return this._cmdCancel;
            }
            
            set
            {
                this._cmdCancel = value;
            }
        }

        private ImageButton cmdCancelIcon
        {
           
            get
            {
                return this._cmdCancelIcon;
            }
            
            set
            {
                this._cmdCancelIcon = value;
            }
        }

        private LinkButton cmdFinish
        {
           
            get
            {
                return this._cmdFinish;
            }
            
            set
            {
                this._cmdFinish = value;
            }
        }

        private ImageButton cmdFinishIcon
        {
           
            get
            {
                return this._cmdFinishIcon;
            }
            
            set
            {
                this._cmdFinishIcon = value;
            }
        }

        private LinkButton cmdHelp
        {
           
            get
            {
                return this._cmdHelp;
            }
            
            set
            {
                this._cmdHelp = value;
            }
        }

        private ImageButton cmdHelpIcon
        {
           
            get
            {
                return this._cmdHelpIcon;
            }
            
            set
            {
                this._cmdHelpIcon = value;
            }
        }

        private LinkButton cmdNext
        {
           
            get
            {
                return this._cmdNext;
            }
            
            set
            {
                this._cmdNext = value;
            }
        }

        private ImageButton cmdNextIcon
        {
           
            get
            {
                return this._cmdNextIcon;
            }
            
            set
            {
                this._cmdNextIcon = value;
            }
        }

        public int CurrentPage
        {
            get
            {
                if (this.ViewState["CurrentPage"] == null)
                {
                    this.ViewState["CurrentPage"] = 0;
                }
                return (int) this.ViewState["CurrentPage"];
            }
            set
            {
                this.ViewState["CurrentPage"] = value;
            }
        }

        public bool EnableBack
        {
            get
            {
                return this.m_EnableBack;
            }
            set
            {
                this.m_EnableBack = value;
            }
        }

        public bool EnableFinish
        {
            get
            {
                return this.m_EnableFinish;
            }
            set
            {
                this.m_EnableFinish = value;
            }
        }

        public bool EnableNext
        {
            get
            {
                return this.m_EnableNext;
            }
            set
            {
                this.m_EnableNext = value;
            }
        }

        public int FinishPage
        {
            get
            {
                if (this.ViewState["FinishPage"] == null)
                {
                    this.ViewState["FinishPage"] = 0;
                }
                return (int) this.ViewState["FinishPage"];
            }
            set
            {
                this.ViewState["FinishPage"] = value;
            }
        }

        private Image imgIcon
        {
           
            get
            {
                return this._imgIcon;
            }
            
            set
            {
                this._imgIcon = value;
            }
        }

        private Label lblHelpTitle
        {
           
            get
            {
                return this._lblHelpTitle;
            }
            
            set
            {
                this._lblHelpTitle = value;
            }
        }

        private Label lblPages
        {
           
            get
            {
                return this._lblPages;
            }
            
            set
            {
                this._lblPages = value;
            }
        }

        private Label lblTitle
        {
           
            get
            {
                return this._lblTitle;
            }
            
            set
            {
                this._lblTitle = value;
            }
        }

        public WizardPageCollection Pages
        {
            get
            {
                return this.m_Pages;
            }
        }

        public WizardPage SuccessPage
        {
            get
            {
                return this.m_SuccessPage;
            }
            set
            {
                this.m_SuccessPage = value;
            }
        }

        private HtmlGenericControl WizardHelp
        {
           
            get
            {
                return this._WizardHelp;
            }
            
            set
            {
                this._WizardHelp = value;
            }
        }

        private HtmlTableCell WizardHelpPane
        {
           
            get
            {
                return this._WizardHelpPane;
            }
            
            set
            {
                this._WizardHelpPane = value;
            }
        }
    }
}

